<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="com.deltabravomedia.theoldtoad.server.Item" %>
<%@ page import="com.deltabravomedia.theoldtoad.server.PMF" %>
<%@ page import="com.google.appengine.api.datastore.Key" %>
<%@ page import="com.google.appengine.api.datastore.KeyFactory" %>
<html>
<head><title>The Old Toad Mobile Application Data Control</title></head>
<body>
<h1>The Old Toad Mobile Application Data Control</h1>

<a href="/update.jsp">Return to Main Page</a>

<h2>Event</h2>
<form action="/createItem?Event" method="post">
<table border="1">
<tr><th>Name</th><th>Cost</th><th>Description</th><th>We Recommend</th><th></th><th></th></tr>
<%
    PersistenceManager pm = PMF.get().getPersistenceManager();
    String query = "select from " + Item.class.getName() + " where type == 'Event' order by date";
    List<Item> items = (List<Item>) pm.newQuery(query).execute();
    if (items.isEmpty()) {
%>
<%
    } else {
        for (Item item : items) {
        	String keyString = KeyFactory.keyToString(item.getKey());
        
%>
<tr><td><pre><%=item.getName()%></pre></td><td><pre><%=item.getCost()%></pre></td>
<td><pre><%=item.getDescription()%></pre></td>
<td><a href="/deleteItem?<%=keyString%>">Delete</a></td></tr>
<%
        }
    }
    pm.close();
%>
<tr><td><textarea name="name" rows="2" cols="30"></textarea></td>
<td><textarea name="cost" rows="2" cols="30"></textarea></td>
<td><textarea name="description" rows="6" cols="60"></textarea></td>
<td><input type="submit" value="Add Event" /></td></tr>
<input type="hidden" name="type" value="Event">
</table>
</form>

</body>
</html>